package net.wang.cloud.order.web;


import net.wang.cloud.dto.OrderDTO;
import net.wang.cloud.order.domain.Order;
import net.wang.cloud.order.service.OrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(value = "api/order")
public class OrderController {

    @Resource
    OrderService orderService;

    @GetMapping(value = "/all")
    public List<Order> findAll() {
        return orderService.all();
    }

    @GetMapping(value = "/{id}")
    public OrderDTO findOne(@PathVariable Long id) {
        return orderService.getOrder(id);
    }


    @PostMapping(value = "/create")
    public void findOne(@RequestBody OrderDTO orderDTO) {
         orderService.createOrder(orderDTO);
    }


}
